package com.lgx.mall.business.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lgx.common.exception.DataException;
import com.lgx.mall.business.dao.IOrderDetailDao;
import com.lgx.mall.business.entity.OrderDetail;
import com.lgx.mall.business.service.IOrderDetailService;

/**
 * 
 * @author acer
 *
 */
@Service
public class OrderDetailService implements IOrderDetailService {
	
	@Autowired
	private IOrderDetailDao orderDetailDao;

	public IOrderDetailDao getOrderDetailDao() {
		return orderDetailDao;
	}

	public void setOrderDetailDao(IOrderDetailDao orderDetailDao) {
		this.orderDetailDao = orderDetailDao;
	}

	@Override
	public OrderDetail createOrderDetail(OrderDetail detail) {
		try {
			return this.orderDetailDao.createOrderDetail(detail);
		} catch (DataException e) {
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public OrderDetail updateOrderDetail(OrderDetail detail) {
		try {
			return this.orderDetailDao.updateOrderDetail(detail);
		} catch (DataException e) {
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public void deleteOrderDetail(OrderDetail detail) {
		try {
			this.orderDetailDao.deleteOrderDetail(detail);
		} catch (DataException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void deleteOrderDetail(long id) {
		try {
			this.orderDetailDao.deleteOrderDetail(id);
		} catch (DataException e) {
			e.printStackTrace();
		}
	}

	@Override
	public OrderDetail findOrderDetailById(long id) {
		return this.orderDetailDao.findOrderDetailById(id);
	}

	@Override
	public List<OrderDetail> findOrderDetailList(long orderId) {
		return this.orderDetailDao.findOrderDetailList(orderId);
	}

	@Override
	public String checkOrderDetail(long orderId, long productId) {
		return this.orderDetailDao.checkOrderDetail(orderId, productId);
	}
}
